CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(BMPANEL)
SET(BMPANEL_VERSION_MAJOR "2")
SET(BMPANEL_VERSION_MINOR "0")
SET(BMPANEL_VERSION_MICRO "0")
SET(BMPANEL_VERSION_EXTRA "a")
SET(BMPANEL_VERSION "${BMPANEL_VERSION_MAJOR}.${BMPANEL_VERSION_MINOR}")
SET(BMPANEL_VERSION_FULL
	"${BMPANEL_VERSION}.${BMPANEL_VERSION_MICRO}.${BMPANEL_VERSION_EXTRA}")

SET(BMPANEL_EXECUTABLE_NAME "bmpanel${BMPANEL_VERSION_MAJOR}")

# always compile with -Wall
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")

SET(SOURCES
	${CMAKE_CURRENT_SOURCE_DIR}/memory.c
	${CMAKE_CURRENT_SOURCE_DIR}/message.c 
	${CMAKE_CURRENT_SOURCE_DIR}/config-parser.c 
	${CMAKE_CURRENT_SOURCE_DIR}/bmpanel.c
	${CMAKE_CURRENT_SOURCE_DIR}/xutil.c
	${CMAKE_CURRENT_SOURCE_DIR}/panel.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_taskbar.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_clock.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget-interface.c
	${CMAKE_CURRENT_SOURCE_DIR}/image-cache.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget-utils.c
	${CMAKE_CURRENT_SOURCE_DIR}/event-dispatchers.c
	${CMAKE_CURRENT_SOURCE_DIR}/xdg.c
	${CMAKE_CURRENT_SOURCE_DIR}/settings.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_decor.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_desktops.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_systray.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_launchbar.c
	${CMAKE_CURRENT_SOURCE_DIR}/widget_empty.c
	${CMAKE_CURRENT_SOURCE_DIR}/render_normal.c
	${CMAKE_CURRENT_SOURCE_DIR}/render_pseudo.c
	${CMAKE_CURRENT_SOURCE_DIR}/args.c
	${CMAKE_CURRENT_SOURCE_DIR}/strbuf.c
)

# xlib
FIND_PACKAGE(X11 REQUIRED)

# pkg-config packages
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(CAIRO REQUIRED cairo)
PKG_CHECK_MODULES(PANGO REQUIRED pangocairo)

# i can use FindGTK here probably, but since I need only glib.. 
PKG_CHECK_MODULES(GLIB REQUIRED glib-2.0)
PKG_CHECK_MODULES(GTHREAD REQUIRED gthread-2.0)

INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS}
	${GLIB_INCLUDE_DIRS} ${GTHREAD_INCLUDE_DIRS} ${PANGO_INCLUDE_DIRS})
	
ADD_EXECUTABLE(${BMPANEL_EXECUTABLE_NAME} ${SOURCES})
TARGET_LINK_LIBRARIES(${BMPANEL_EXECUTABLE_NAME} ${X11_LIBRARIES}
	${CAIRO_LIBRARIES} ${GLIB_LIBRARIES} ${GTHREAD_LIBRARIES} ${PANGO_LIBRARIES})

ADD_SUBDIRECTORY(man)

# default installation dirs
IF (NOT BMPANEL2_BINARY_PATH)
	SET(BMPANEL2_BINARY_PATH bin)
ENDIF (NOT BMPANEL2_BINARY_PATH)

IF (NOT BMPANEL2_DATA_PATH)
	SET(BMPANEL2_DATA_PATH share/bmpanel2)
ENDIF (NOT BMPANEL2_DATA_PATH)

# install commands
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${BMPANEL_EXECUTABLE_NAME}
	DESTINATION ${BMPANEL2_BINARY_PATH})
INSTALL(DIRECTORY themes
	DESTINATION ${BMPANEL2_DATA_PATH})
